home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / drdtips.zip / 1118.TXT < prev    next >
Text File  |  1993-01-07  |  5KB  |  144 lines

  1.                                 FYI
  2.  
  3. (Note: The origin of this information may be internal or external
  4. to Novell.  Novell makes every effort within its means to verify
  5. this information.  However, the information provided in this
  6. document is FOR YOUR INFORMATION only.  Novell makes no explicit or
  7. implied claims to the validity of this information.) 
  8.  
  9.           TITLE: Batch Programming and Zero Byte Files
  10.    DOCUMENT ID#: FYI-M-1118
  11.            DATE: 13OCT92
  12.         PRODUCT: DR DOS
  13. PRODUCT VERSION: 6.0
  14.      SUPERSEDES: N/A
  15.  
  16.         SYMPTOM: Unable to copy zero byte files.
  17.  
  18. ISSUE/PROBLEM
  19. Since the release of DR DOS it has always had the ability to copy
  20. zero byte files. Recently we have found, however, that by limiting
  21. the ability of DR DOS to copy such files, we can increase the
  22. abilities of batch programs.  This change has been made in the 7-92
  23. and 11-92 COMMAND.COM. This latest COMMAND.COM is available on
  24. CompuServe or the Novell DSG Host BBS (408-649-3443). 
  25.  
  26. One example of this is the ability to create a batch program that
  27. will only execute a certain command or group of commands once a
  28. day.
  29.  
  30. The following is a set of instructions that will generate an
  31. example of a batch file and it's necessary text files that can be
  32. executed multiple times daily (say from the AUTOEXEC.BAT file), but
  33. will only perform the defined task once a day:
  34.  
  35. 1.   Create a file called DTFRCMP.TXT that contains the current
  36.      date information by typing the following from the command
  37.      line:
  38.  
  39.      C:\>DATE >DTFRCMP.TXT
  40.      Press the Enter key twice and you will be returned to a
  41.      prompt.
  42.  
  43. 2.   Create a file called CR using the editor (EDITOR.EXE). All
  44.      that this file will contain will be a carriage return. To
  45.      create it do the following:
  46.  
  47.      a.   From the command line (C:\>) type: EDITOR CR
  48.      b.   You will then be asked if you wish to create a new file.
  49.           Type Y.
  50.      c.   You will then be in the editor.  Enter a carriage return
  51.           by pressing the ENTER key once.
  52.      d.   You will then need to save the file.  Do this by holding
  53.           the Ctrl key down and then typing K and then X.
  54.  
  55. 3.   Now you will need to create the main batch file that performs
  56.      the daily routine.
  57.  
  58.      a.   From the command line (C:\>) type: EDITOR TEST.BAT
  59.      b.   You will then be asked if you wish to create a new file. 
  60.           Type Y.
  61.      c.   Then proceed to type in the following lines (thus
  62.           creating the file):
  63.  
  64. @ECHO OFF
  65. REM This logs the date information into a file.
  66. DATE <CR >INF.TXT
  67. REM This compares the preexisting date information
  68. REM with the date information that was just created.
  69. REM It creates a file with this information.
  70. COMP INF.TXT DTFRCMP.TXT >CMP.RZT
  71.  
  72. REM This looks for the word "failure" in the created
  73. REM text file. (This would be an indication that the
  74. REM files are the same if "failure" was not found)...
  75. REM Thus telling us that this batch file has already
  76. REM been run today.
  77. REM It pipes the results into a file.
  78. FIND "FAILURE" CMP.RZT >DECIDER.TXT
  79.  
  80. REM If "failure" was found, then the file that was 
  81. REM created will have a file size.  If it was not
  82. REM found then it will have a zero byte file size.
  83. REM This will try to copy the file to another file.
  84. REM If the original file is a zero byte file then
  85. REM this procedure will fail because the COPY 
  86. REM command cannot copy a zero byte file.
  87. COPY DECIDER.TXT FINAL.TXT >NUL
  88.  
  89. REM This checks to see if the final file was created.
  90. REM If it was not, then the daily routine will be
  91. REM bypassed...this batch file has already been run today.
  92. IF NOT EXIST FINAL.TXT GOTO FINAL
  93.  
  94. REM If this section has been reached, then the batch
  95. REM file has not been run today and it is going to 
  96. REM execute the once-a-day command that it is intended
  97. REM to execute. This can be any command of your choosing
  98. REM as long as it works from the DOS prompt.  The one that
  99. REM has been chosen here is a command that copies the
  100. REM config.sys file to a filename called ITWORKED.SYS.
  101. :COPY
  102. COPY C:\CONFIG.SYS C:\ITWORKED.SYS >NUL
  103. ECHO Executing once-a-day routine...
  104. REM This creates a new date-comparison file so that the
  105. REM next time that this batch file is run it will see 
  106. REM that it has already been run today.
  107.  
  108. COPY INF.TXT DTFRCMP.TXT >NUL
  109.  
  110. REM This deletes the final comparison file that was created
  111. REM today.
  112. DEL FINAL.TXT
  113.  
  114. REM This cleans up all of the extra files and exits.
  115. :END
  116. DEL INF.TXT
  117. DEL CMP.RZT
  118. DEL DECIDER.TXT
  119. EXIT
  120.  
  121. REM This tells you that it has already been run today.
  122. :FINAL
  123. echo Daily routine has already been run today.
  124. GOTO END
  125.  
  126.  
  127. Now, if TEST.BAT is executed many times daily, it will only create
  128. the file ITWORKED.SYS once a day.
  129.  
  130. Please note: If you attempt to run this batch file on the same day
  131. that you created it, it will respond that the routine has already
  132. been run today.  This is because the information in the DTFRCMP.TXT
  133. file is the same as the current day's date.  If you wish to test
  134. it, you will have to change the date.
  135.  
  136. This file can be incorporated in the AUTOEXEC.BAT file to execute
  137. every time the computer is turned on.  To do this, use the editor
  138. and add the following line just before the line :DRDOSEND:
  139.  
  140. CALL TEST.BAT
  141.  
  142. Some possible uses of such a batch file would be running a daily
  143. virus scan, running system diagnostics or running the disk
  144. optimizer.